from fastapi import APIRouter

from config.dependencies import UserServiceDep
from schemas.users import UserCreate, UserResponse, UsersResponse, UserUpdate

users = APIRouter(prefix="/users", tags=["users"],)


@users.post("/", response_model=UserResponse)
async def create_user(user_data: UserCreate, service: UserServiceDep):
     return service.create_user(user_data)



@users.delete("/", response_model=None)
async def delete_user(user_id: int, service: UserServiceDep):
     return service.delete_user(user_id)



@users.get("/", response_model=UsersResponse)
async def get_users(page: int | None = None, size: int | None = None,username: str | None = None, service: UserServiceDep = UserServiceDep):
     return service.filter_user(page, size, username)



@users.get("/user/", response_model=UserResponse)
async def get_user_by_id(user_id: int ,service: UserServiceDep = UserServiceDep):
    return service.get_user_by_id(user_id)


@users.put("/", response_model=UserResponse)
async def update_user(user_data: UserUpdate, service: UserServiceDep = UserServiceDep):
     return service.update_user(user_data)
